<?php
echo "<h1>string manange</h1>";
//字符串去除空格
//trim($a,"t")  去除字符串内所有空格   第二个参数为要移除的字符串，可以为空
//ltrim($a,"t") 去除字符串最左端空格
//rtrim($a,"t") 去除字符串最右端空格
$string_arg1="test o 8*";
echo "</br>print arg1:";
echo $string_arg1;
echo "</br>remove space and *:";
echo trim($string_arg1,"*");  

//ltrim
$string_arg2="o o ssss.. o";
echo "</br>ltrim:";
echo ltrim($string_arg2,"o");

//rtrim
echo "</br>rtrim:";
echo rtrim($string_arg2,"o");


//字符串转换大小写  注意：不能嵌套使用
//strtolower   转换为小写
//strtoupper   转换为大写

//strtolower
echo "</br>strtolower:".strtolower("I like make loVe");

//strtoupper
echo "</br>strtoupper:".strtoupper("I like make loVe");

//ucfirst 首字母大写
echo "</br>ucfirst:".ucfirst("understand!");

//ucwords 单词首字母大写
echo "</br>ucwords:".ucwords("my name  is super man!");

//字符串的比较
//!=    ==
$string_arg3="zhang";
$string_arg4="wang";
$string_arg5="zhang";
echo "</br>".($string_arg3==$string_arg4?"zhang=wang":"zhang!=wang");
echo "</br>".($string_arg3!=$string_arg5?"zhang!=zhang":"zhang=zhang");

//strcmp($a,$b); 区分大小写比较
$string_arg6="zhang";
$string_arg7="Zhang";
echo "</br>strcmp:".strcmp($string_arg6,$string_arg7);

//strcasecmp($a,$b); 不区分大小写比较
echo "</br>strcasecmp:".strcasecmp($string_arg6,$string_arg7);

//strncmp($a,$b,len); 区分大小写 ，截取比较
echo "</br>strncmp:".strncmp($string_arg6,$string_arg7,3);

//strncasecmp($a,$b,len); 不区分大小写，截取比较
echo "</br>strncasecmp:".strncasecmp($string_arg6,$string_arg7,3);

//截取字符串
//strstr($parent,$child) 截取child第一次出现的位置结束
$string_arg8="Jack  is  a  good  boy,we are very  friendly!";
echo "</br>strstr:".strstr($string_arg8,"a");
//strrchr($parent,$child) 截取child最后一次出现的位置结束
echo "</br>strrchr:".strrchr($string_arg8,"a");

//substr_count($parent,$child,int startindex,int endindex) 3和4参数为选填
// 查找一个字符串在  另外一个字符串中出现的次数
echo "</br>substr_count:".substr_count($string_arg8,"a");

//strrpos($parent,$search,int startIndex)
//查找一个字符串在另一个字符串中最后一次出现的位置
echo "</br>strrpos:".strrpos($string_arg8,"a");

//strpos($parent,$search,int startIndex)
//查找一个字符串在另一个字符串中第一次出现的位置
echo "</br>strpos:".strpos($string_arg8,"a",10);

//str_replace($old,$new,$target) 
//将target中的 old  用 new替换
echo "</br>str_replace:".str_replace("a","c",$string_arg8);

//substr_replace($target,$replace,$startIndex,$lenth)
//部分替换
echo "</br>substr_replace:".substr_replace($string_arg8,"TEST",3,5);

//explode($cutChar,$target,$count=?);
//字符串分割
echo "</br>explode:";
print_r(explode(" ",$string_arg8));

//MD5($str) md5加密, 一般用于密码
echo "</br>before secret:".$string_arg8;
echo "</br>end secret:".md5($string_arg8);
echo  "</br>";
//格式化输出 printf  和  sprintf
echo "</br>printf:".printf("%0.1f","18.33333");

echo "</br>sprintf:".sprintf("%0.3f","18.33333");
echo "<u>test</u>";

echo "</br>".(5/3%3);
?>